$input_tped = $ARGV[0];
$output_tped = $ARGV[1];
$maindir = $ARGV[2];
chomp($input_tped);
chomp($output_tped);
chomp($maindir);
open(BUFF,$input_tped);
open(WRBUFF,">$maindir/new4_temp");

for($i=1;$i<23;$i++)
{
	${"A$i"} = "A$i";

}
$A23 = "X";
$A24 = "Y";
$A26 = "M";
while($line = <BUFF>)
{
	@array = split(" ",$line);
	print WRBUFF ${"A$array[0]"}."\t".$array[1]."\t".$array[2]."\t".$array[3]."\n";

}
system("sort -k1,1 -k4,4n -k2,2 $maindir/new4_temp |cut -f2 > $output_tped");
system("rm $maindir/new4_temp");
